import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-14
 * Time: 14:56
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        Stack<Integer> stack = new Stack<>();
        int num = in.nextInt();
        while (num != 0) {
            stack.push(num % 2);
            num /= 2;
        }

        StringBuilder sb = new StringBuilder();
        while (!stack.isEmpty()) {
            sb.append(stack.pop());
        }
        int max = 0, left = 0, right = 0;
        while (right < sb.length()) {
            while (right < sb.length() && sb.charAt(right) == '0') {
                right++;
            }
            left = right;
            while (right < sb.length() && sb.charAt(right) == '1') {
                right++;
            }
            max = Math.max(max,right - left);
        }

        System.out.println(max);
    }
}